/*
 * @Description: 
 * @Autor: kaikaima
 * @Date: 2021-03-04 20:51:20
 * @LastEditors: kaikaima
 * @LastEditTime: 2021-04-07 12:04:54
 */
#include <iostream>
#include <chrono>
#include "Linear_equations.h"

int main (int argc, char* argv[]){
    typedef std::chrono::high_resolution_clock myclock;
    int num; std::cin>>num;
    L_Equations question(num);
    double* KEY[num+1];
    double* B;
    for(int i=0;i<=num;i++)
        KEY[i]=new double[num];
    for(int i=0;i<=num;i++)
    for(int j=0;j<num;j++)
        std::cin>>KEY[i][j];
    
    question.set(KEY);
    myclock::time_point beginning = myclock::now();
    B=question.Gauss_solve();
    myclock::duration d = myclock::now()-beginning;
    std::cout<<"列主元高斯消元法："<<std::endl<<"("<<B[0];
    for(int i=1;i<num;i++) std::cout<<", "<<B[i];
    std::cout<<")^T"<<std::endl;
    std::cout<<"time: "<<d.count()<<std::endl;

    question.set(KEY);
    beginning = myclock::now();
    B=question.Gauss_solve_original();
    d = myclock::now()-beginning;
    std::cout<<"高斯消元法："<<std::endl<<"("<<B[0];
    for(int i=1;i<num;i++) std::cout<<", "<<B[i];
    std::cout<<")^T"<<std::endl;
    std::cout<<"time: "<<d.count()<<std::endl;

    question.set(KEY);
    beginning = myclock::now();
    B=question.Cholesky_solve();
    d = myclock::now()-beginning;
    std::cout<<"平方根法："<<std::endl<<"("<<B[0];
    for(int i=1;i<num;i++) std::cout<<", "<<B[i];
    std::cout<<")^T"<<std::endl;
    std::cout<<"time: "<<d.count()<<std::endl;

    question.set(KEY);
    beginning = myclock::now();
    B=question.Cholesky_solve_modified();
    d = myclock::now()-beginning;
    std::cout<<"改良的平方根法："<<std::endl<<"("<<B[0];
    for(int i=1;i<num;i++) std::cout<<", "<<B[i];
    std::cout<<")^T"<<std::endl;
    std::cout<<"time: "<<d.count()<<std::endl;

    for(int i=0;i<=num;i++)
        delete KEY[i];
    return 0;
}